#include<iostream>
using namespace std;
const int N = 1e7 + 10;
typedef long long LL;
LL prime[N];
LL a, b, x;
int cnt;
bool st[N];
void fun()
{
	for (int i = 2; i <= N; i++) {
		if (!st[i]) {
			prime[cnt++] = i;
			for (int j = i * 2; j <= N; j += i) {
				st[j] = 1;
			}	
		}
	}
}
int main()
{
	int t;
	cin >> t;
	fun();
	while (t--) {
		cin >> x;
		for (int i = 0; i < cnt; i++) {
			b = prime[i] + x;
			if (b % prime[i] != 0) {
				cout << prime[i] << " " << b << endl;
				break;
			}
		}
	}
	return 0;
}